using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Net;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.IO;
using Transport;

namespace SendKeys
{
    public partial class SendKeysToApps : Form
    {
        private bool isStartClient;
        private Client client;
        
        /// <summary>
        /// Default constructor
        /// </summary>
        public SendKeysToApps()
        {
            InitializeComponent();
            this.Focus();

        }
        

        private void btnConnection_Click(object sender, EventArgs e)
        {
            if (!isStartClient)
            {
                client = new Client(IPAddress.Parse(boxIp.Text), 9595);
                isStartClient = client.Connect();
            }
            this.Focus();
            
        }

        private void SendKeysToApps_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (isStartClient)
                client.CloseConnection();
        }

        

        private void btnConnection_KeyDown(object sender, KeyEventArgs e)
        {
            client.SendKey("{" + e.KeyData + "}");
        }

    }
}